<html lang="zh-cn" >
<head>
    <meta charset="utf-8" />
    <meta HTTP-EQUIV="pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <meta HTTP-EQUIV="expires" CONTENT="0">
    <meta name="apple-touch-fullscreen" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no" media="screen"/>
    <title>对话窗口</title>
    <link rel="icon" type="image/png" href="../../img/icon.png">
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/message.css">
    <link rel="stylesheet" type="text/css" href="../css/msgWin.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="/h5/js/all.js"></script>
    <style type="text/css">
    </style>
</head>
<body>
<div id="msgTitle">
    <b>招聘来自<span id="titleName">XX</span></b>
    <img src="../images/return.png" id="msgComRtn">
</div>

<div class="speak_window">
    <div class="speak_box" id="scrollDiv">
        <div class="answer">
            <div class="heard_img left" style="background:#ffffff;">
                <img src="../images/toux01.png" height="20">
            </div>
            <div class="answer_text">
                <p>Hi，欢迎来此交流！</p>
                <i></i>
            </div>
        </div>
    </div>
</div>

<table class="moreMenu">
    <tr>
        <td>
            <select id="joblist"
                    onchange="$('jobId')[0].value=this.value;">
                <option value="0">选择岗位</option>
            </select>
        </td>
        <td>
            <a href="javascript:;" onclick="sendResume()">发送简历</a>
        </td>
    </tr>
    <tr>
        <td>
            <a href="javascript:;" onclick="getRecruitMsg()">招聘消息</a>
        </td>
        <td>
            <a href="javascript:;" onclick="getRecruitFlow()">招聘流程</a>
        </td>
    </tr>
    <tr>
        <td>
            <a href="javascript:;" onclick="getJobAccept()">刷新消息</a>
        </td>
        <td>
        <td>
            <a href="javascript:;" onclick="getMyRecruit()">我的招聘</a>
        </td>
        </td>
    </tr>
</table>

<div class="wenwen-footer">
    <!--<div class="wenwen_btn left" onclick="getJobAccept()">刷新</div>-->
    <div class="wenwen_btn left"
         onclick="$('.moreMenu').toggle();">
        更多
    </div>
    <div class="wenwen_text left">
        <div class="write_box">
            <input type="text" id="quest" class="left" placeholder="请输入关键字"/>
        </div>
    </div>
    <div class="wenwen_help right">
        <button class="right" onclick="setJobSend()">发送</button>
    </div>
    <div class="clear"></div>
</div>
<input type="hidden" id="talkId" value="0">
<input type="hidden" id="own" value="0">
<input type="hidden" id="other" value="0">
<input type="hidden" id="otherName" value="0">
<input type="hidden" id="jobId" value="0">





<!----------错误提示---------->
<div id="errMsg"></div>
<!----------错误提示---------->

<script type="text/javascript" src="../js/cache.js"></script>
<script type="text/javascript" src="../js/app.js"></script>
<script type="text/javascript" src="../js/messagePageChange.js"></script>
<script type="text/javascript" src="../js/msg.js"></script>
<script type="application/javascript">
    (function(){
        var talkId = getUrlParam('id');
        var own = getUrlParam('own');
        var other = getUrlParam('other');
        var otherName = getUrlParam('otherName');
        var jobId = getUrlParam('jobId');
        if (otherName.length > 6) {
            otherName = otherName.substring(0,6) + '...';
        }
        $('#talkId')[0].value = talkId;
        $('#own')[0].value = own;
        $('#other')[0].value = other;
        $('#otherName')[0].value = otherName;
        $('#jobId')[0].value = jobId;
        $('#titleName').html(otherName);
        getJobAccept(); //获取招聘消息
//        getTalkCache(); //获取本地缓存
        getJobListByCid();
    })();
    /**
     * 去招聘消息
     * */
    function getRecruitMsg(){
        window.location.href = '/h5/message/job.html';
    }
    /**
     * 去招聘流程
     * */
    function getRecruitFlow(){
        var userInfo = cacheGet('userInfo');
        var view = '';
        if (userInfo.type==1) {
            view = 'comJob.html';
        } else {
            view = 'comPub.html';
        }
        window.location.href = '/h5/my/'+view;
    }
    /**
     * 去我发布的
     * */
    function getMyRecruit(){
        var userInfo = cacheGet('userInfo');
        var view = '';
        if (userInfo.type==1) {
            view = 'staff.html';
        } else {
            view = 'com.html';
        }
        window.location.href = '/h5/my/job/'+view;
    }
    /**
     * 获取岗位，当前工人
     * */
    function getJobListByCid(){
        var userInfo = cacheGet('userInfo');
        var cid = getUrlParam('other');
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            cid:cid,
            type:1 //1工人，2企业
        };
        $.ajax({
            type:'post',
            url:'/api/home/recruit/jobsbycid',
            data:formData,
            success:function(res){
                //console.log(res); return
                var  h = '';
                if (res.code!=0) {
                    console.log(res);
                    $('#joblist').html('<option>没有岗位</option>');
                    getAppErrMsg(res.msg,'',0);
                    return
                }
                var resData = res.data;
                for (var i=0;i<resData.length;i++) {
                    h += '<option value="'+resData[i].id+'" ';
                    h += ' >';
                    h += resData[i].name;
                    h += '</option>';
                }
                $('#joblist').html(h);
            },
            error:function(){
                console.log('操作失败！')
            }
        });
    }
    /**
     * 发送简历
     * */
    function sendResume(){
        var userInfo = cacheGet('userInfo');
        var cid = getUrlParam('other');
        var jobId = getUrlParam('jobId');
        if (jobId==0) {
            getAppErrMsg('岗位未选择！','',0);
            return
        }
        var formData = {
            app_access:app_access,
            token:userInfo.token,
            cid:cid,
            job:jobId
        };
//        console.log(formData); return
        $.ajax({
            type:'post',
            url:'/api/home/recruit/resume-add',
            data:formData,
            success:function(res){
                //console.log(res); return
                if (res.code==-41) {
                    console.log(res);
                    $('.moreMenu').hide();
                    getAppErrMsg('您的简历早已发送！','',0);
                    return
                } else if (res.code!=0) {
                    console.log(res);
                    getAppErrMsg(res.msg,'',0);
                    return
                }
                var resData = res.data;
                getAppErrMsg('发送成功！','',0);
            },
            error:function(){
                console.log('操作失败！')
            }
        });
    }
    //    /**
    //     * 本地对话获取
    //     * */
    //    function getTalkCache(){
    //        var talkCache = cacheGet('msgJob');
    //        console.log(talkCache)
    //        if (talkCache=='' || talkCache==null) {
    //            console.log('没有历史缓存！'); return;
    //        }
    //        var i, h = '';
    //        for (i=0;i<talkCache.length;i++) {
    //            var head = '';
    //            if (talkCache[i].head=='') {
    //                head = '../images/toux01.png';
    //            } else {
    //                head = talkCache[i].head;
    //            }
    //            if (talkCache[i].align=='right') {
    //                h += '<div class="question">';
    //                h += '<div class="heard_img right">';
    //                h += '<img src="'+head+'" height="40">';
    //                h += '</div>';
    //                h += '<div class="question_text">';
    //                h += '<p>'+talkCache[i].detail+'</p>';
    //                h += '<i></i>';
    //                h += '</div>';
    //                h += '</div>';
    //            } else {
    //                h += '<div class="answer">';
    //                h += '<div class="heard_img left">';
    //                h += '<p>'+talkCache[i].detail+'</p>';
    //                h += '</div>';
    //                h += '<div class="answer_text">';
    //                h += '<p>'+talkCache[i].detail+'</p>';
    //                h += '<i></i>';
    //                h += '</div>';
    //                h += '</div>';
    //            }
    //        }
    //        $('.speak_box').append(h);
    //        console.log('获取缓存成功！');
    //    }
</script>
</body>
</html>